package com.linwen.javase.string;

/**
 * @ClassName StringBuilderThread
 * @Description
 * @Author lin
 * @Date 2022/3/19 下午4:09
 * @Version V1.0
 */
public class StringBuilderThread implements Runnable{
    StringBuilder stringBuilder = new StringBuilder();
    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            // 跟stringBuffer一样
//            synchronized (this){
//                stringBuilder.append(i%10);
//            }
            stringBuilder.append(i%10);
        }
    }
    public String stringBuilderToString(){
        return stringBuilder.toString();
    }
}
